<template>
  <div id="comments">
    <div class="top" v-for="b in list" :key="b.id">
      <van-icon class="lt" color="#999" name="arrow-left" @click="fn" />
      <span>商品评价</span>
    </div>
    <div class="one" v-for="a in list" :key="a.id">
      <img :src="a.url" alt="" />
      <span>{{ a.name }}</span>
    </div>
    <div class="nav">
      <span class="a1">全部评论</span>
      <span>有图/视频</span>
      <span>好评1W+</span>
      <span>差评99</span>
    </div>
    <div class="wrapper">
      <ul class="main">
        <li>
          <img class="tx" src="../../assets/商品评价img/tx7.jpg" alt="" />
          <span class="name">大师兄</span>
          <span class="time">1982.7.21</span>
          <p>口味还不错，俺老孙很喜欢!</p>
          <div class="tp">
            <img class="" src="../../assets/商品评价img/西梅.png" alt="" />
          </div>
        </li>
        <li>
          <img class="tx" src="../../assets/商品评价img/tx4.jpg" alt="" />
          <span class="name">二师兄</span>
          <span class="time">1982.7.21</span>
          <p>这口感？！比俺老猪在高老庄吃的都甜!</p>
          <div class="tp">
            <img src="../../assets/商品评价img/西梅.png" alt="" />
            <img src="../../assets/商品评价img/西梅评论.png" alt="" />
          </div>
        </li>
        <li>
          <img class="tx" src="../../assets/商品评价img/tx5.jpg" alt="" />
          <span class="name">沙师弟</span>
          <span class="time">1982.7.21</span>
          <p>香香香香香香香香香香香香香香</p>
          <div class="tp">
            <img src="../../assets/商品评价img/西梅.png" alt="" />
          </div>
        </li>
        <li>
          <img class="tx" src="../../assets/商品评价img/tx6.jpg" alt="" />
          <span class="name">师傅</span>
          <span class="time">1982.7.21</span>
          <p>徒儿们，双十二给师傅买两斤回来...</p>
          <div class="tp">
            <img src="../../assets/商品评价img/西梅评论.png" alt="" />
            <img src="../../assets/商品评价img/西梅.png" alt="" />
          </div>
        </li>
      </ul>
    </div>
    <div class="foont" v-for="d in list" :key="d.id">
      <img src="../../assets/菜谱img/sc.png" alt="" />
      <button class="btn" @click="inCart(d.id)">加入购物车</button>
    </div>
  </div>
</template>
<script>
// import BetterScroll from "better-scroll";
import { mapState } from "vuex";
export default {
  name: "Comments",
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.getList();
    // new BetterScroll(".wrapper", {
    //   scrollY,
    //   click: true,
    // });
  },
  methods: {
    inCart(id) {
      this.$store.commit("inCart", id);
      this.$router.push("/cart");
    },
    fn() {
      this.$router.go(-1);
      // this.$router.push({
      //   path: "/detail",
      //   query: {
      //     id: id,
      //   },
      // });
    },
    getList() {
      this.list = this.goodslist.filter((el) => el.id == this.$route.query.id);
      console.log(this.list);
    },
  },
  computed: {
    ...mapState(["goodslist"]),
  },
};
</script>
<style lang="less" scoped>
.top {
  height: 88px;
  width: 100%;
  background: #ffcc00;
  position: relative;
  text-align: center;
}
.top span {
  position: absolute;
  top: 24px;
  left: 355px;
  height: 39px;
  font-size: 40px;
  font-weight: 800;
  color: #323232;
}
.lt {
  position: absolute;
  left: 10px;
  top: 15px;
}
.one {
  height: 170px;
  width: 100%;
  position: relative;
}
.one img {
  height: 128px;
  width: 128px;
  position: absolute;
  left: 64px;
  top: 30px;
}
.one span {
  position: absolute;
  left: 212px;
  top: 78px;
  height: 33px;
  font-size: 30px;
  font-family: PingFang SC;
  font-weight: 400;
  color: #646464;
}
.nav {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: auto;
}
.nav .a1 {
  color: #000000;
}
.nav span {
  width: 133px;
  font-size: 30px;
  font-family: PingFang SC;
  font-weight: 400;
  color: #868686;
  margin-left: 30px;
  margin-right: 30px;
}
.main {
  position: fixed;
  height: 1040px;
  width: 100%;
  overflow: auto;
}
.main li {
  width: 750px;
  height: 404px;
  margin: 0 auto;
  position: relative;
  border-top: 1px solid rgb(224, 224, 224);
  margin-bottom: 10px;
}
.main .name {
  position: absolute;
  top: 45px;
  left: 170px;
  height: 28px;
  font-size: 30px;
  font-weight: 400;
  color: #646464;
}
.main .time {
  position: absolute;
  right: 34px;
  top: 45px;
  height: 24px;
  font-size: 30px;
  font-family: PingFang SC;
  font-weight: 400;
  color: #646464;
}
.main p {
  position: absolute;
  left: 172px;
  top: 105px;
  height: 31px;
  font-size: 30px;
  font-family: PingFang SC;
  font-weight: 400;
  color: #646464;
}
.main .tp {
  position: absolute;
  top: 160px;
  left: 150px;
  width: 550px;
  height: 250px;
}
.tp img {
  display: inline-block;
  width: 250px;
  height: 250px;
}
.main .tx {
  width: 130px;
  height: 130px;
  position: absolute;
  top: 20px;
}

.foont {
  height: 98px;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
}
.foont img {
  width: 62px;
  height: 47px;
  position: absolute;
  left: 41px;
  top: 25px;
}
.foont .btn {
  position: absolute;
  right: 39px;
  top: 26px;
  width: 539px;
  height: 46px;
  background: #ffcc00;
  border-radius: 20px;
  border: none;
  font-size: 30px;
  font-weight: 400;
  color: #fefefe;
}
</style>
